import './index.css';

// react
import React,{ useState } from 'react';
import {Route,Redirect} from 'react-router-dom';
import {useSelector} from 'react-redux';

// 自定义界面和组件
import Main from '../../components/main';

// 路由
import {addArticleRoute} from '../../router/index';



export default function ManageApp() {
  const {component:AddArticle,path:addArticlePath} = addArticleRoute;

  // todo：要从store中获取
  const isAddArticlePage = useSelector(state => state.AddArticleReducer); // true 时显示添加文章页面，false时显示主页面 
  
  

  return (

    <>
    { 
      isAddArticlePage
        ?
        <>
          <Redirect push={true} to={addArticlePath} />
          <Route exact path={addArticlePath} render={(e) => {
              console.log('addarticlepath',e);
              return isAddArticlePage?<AddArticle />:'';
            }} />
        </>
        :
        <Main />
    }

    </>
    
  );
}